package com.controller;

import com.constant.Constant;
import com.entity.User;
import com.service.ModifyFormService;
import com.util.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;

@RestController
@RequestMapping("/user")
public class ModifyFormController {

    @Autowired
    ModifyFormService modifyFormService;

   @RequestMapping("/modifyUser.do")
   @ResponseBody
        public AjaxResult modifyUser(HttpSession session, User user,String rePassword){
    try {
        user.setPassword(rePassword);
        modifyFormService.updateUserInfo(user);
        User user1 = modifyFormService.selId(user.getId());
        session.setAttribute(Constant.SESSION_USER, user1);
        return AjaxResult.isOk();
    } catch (Exception e) {
        e.printStackTrace();
        return AjaxResult.isFail(e.getMessage());
    }
}

}
